﻿using MongoDB.Driver;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ScreeningTool.Synchronization
{
    public static class EnumerableExtensions
    {
        public static IEnumerable<TSource> Concat<TSource>(params IEnumerable<TSource>[] enumerables)
        {
            var notNullEnumerables = enumerables.Where(x => x != null);
            return notNullEnumerables.Any()
                ? notNullEnumerables.Aggregate(Enumerable.Concat)
                : Enumerable.Empty<TSource>();
        }
    }
}
